from selenium import webdriver

# 指定驱动对象
driver = webdriver.Chrome()

# 打开指定网址
driver.get('http://cdn1.python3.vip/files/selenium/sample2.html')

# 找到 iframe 标签所在
# driver.switch_to.frame('innerFrame')

# 在找到标签的返回对象中，找到 plant id
# elements = driver.find_elements_by_class_name('plant')

driver.switch_to.frame(driver.find_element_by_tag_name('iframe'))

driver.find_element_by_id('searchtext').send_keys('大熊猫')

elements = driver.find_elements_by_class_name('plant')

for element in elements:
    print(element.text)

driver.switch_to.default_content()

driver.find_element_by_id('outerbutton').click()

driver.quit()